package com.xu.system.enums;

import lombok.Getter;

/**
 * 菜单类型枚举
 *
 * @Author: 许乾伟
 * @Date: 2024/3/21 11:15
 */
public enum MenuTypeEnum {
    /**
     * 目录
     */
    DIRECTORY("M", "目录"),
    /**
     * 菜单
     */
    MENU("C", "菜单"),
    /**
     * 按钮
     */
    BUTTON("F", "按钮");

    @Getter
    private String code;
    @Getter
    private String desc;

    MenuTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 通过code获取desc
     * @param code
     * @return
     */
    public static String getDescByCode(String code) {
        for (MenuTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type.desc;
            }
        }
        return "";
    }
}
